clear all
set	more off

cd "~/Dropbox/ors_quality_R01"
use "data/KDG/know_do_gap.dta", clear


/* Controls 
Years of experience: ps_b11
Provider age: ps_b06
Number of patients per day: ps_b37
Number of diarrhea cases per week: ps_b39
Competitive market: comp_cat
Sell medicine/attached pharmacy: ps_dispense
*/

global controls  i.prov_type ps_b11 ps_b06 ps_b37 ps_b39 i.comp_cat ps_dispense

**************
*** Pooled ***
**************

	*extracting control mean
	sum rec_ors if know_ors == 0
	local cntl_mean_ors = r(mean)
	
	sum rec_anti if know_anti == 0
	local cntl_mean_anti = r(mean) 
	
	reg rec_ors i.know_ors $controls severe, robust 
	outreg2 using "tables/know_effect_ors", tex  replace ///
	nocons nor2 nonotes label ///
	keep(1.know_ors) ///
	ctitle("Pooled") ///
	adds(Mean when innacurate response in vignette, `cntl_mean_ors') /// 
	addtext(Controls, Yes) 
	
	reg rec_anti i.know_anti $controls severe, robust
	outreg2 using "tables/know_effect_anti", tex replace ///
	nocons nor2 nonotes label ///
	keep(1.know_anti) ///
	ctitle("Pooled") ///
	adds(Mean when innacurate response in vignette, `cntl_mean_anti') /// 
	addtext(Controls, Yes) 
	

***************
*** By Type ***
***************

forvalues i = 1/4{
	preserve
	
	keep if prov_type==`i'
	
	*extracting control mean
	sum rec_ors if know_ors == 0
	local cntl_mean_ors = r(mean)
	
	sum rec_anti if know_anti == 0
	local cntl_mean_anti = r(mean) 
	
	reg rec_ors i.know_ors $controls severe, robust 
	outreg2 using "tables/know_effect_ors", tex  ///
	nocons nor2 nonotes label ///
	keep(1.know_ors) ///
	ctitle("`i'") ///
	adds(Mean when innacurate response in vignette, `cntl_mean_ors') /// 
	addtext(Controls, Yes) 
	
	reg rec_anti i.know_anti $controls severe, robust
	outreg2 using "tables/know_effect_anti", tex  ///
	nocons nor2 nonotes label ///
	keep(1.know_anti) ///
	ctitle("`i'") ///
	adds(Mean when innacurate response in vignette, `cntl_mean_anti') /// 
	addtext(Controls, Yes) 
	
	restore
}
